﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MobileRecharge.aspx.cs"
    Inherits="OrderManage.WebApp.MobileRecharge" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>手机充值系统</title>

    <script src="lib/jquery-1.6.2.min.js" type="text/javascript"></script>

    <link href="lib/css/MobileRecharge.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div id="main">
        <div id="content">
            <table border="0" cellspacing="1" cellpadding="3" class="table" align="right">
                <tr>
                    <th colspan="4" id="MsgShow">
                        手机充值系统
                    </th>
                </tr>
                <tr>
                    <td width="40%" align="right" class="td1">
                        用户名：
                    </td>
                    <td>
                        <input name="txtUserName" type="text" id="txtUserName" class="input_250" maxlength="18"
                            runat="server" onchange="onUserNameValidation();" /><span class="td_span_red">*</span>
                    </td>
                </tr>
                <tr>
                    <td width="40%" align="right" class="td1">
                        密码：
                    </td>
                    <td>
                        <input name="txtPassword" type="password" id="txtPassword" class="input_250" maxlength="18"
                            runat="server" onchange="onPasswordValidation();" /><span class="td_span_red">*</span>
                    </td>
                </tr>
                <tr>
                    <td width="40%" align="right" class="td1">
                        充值手机：
                    </td>
                    <td>
                        <input name="txtMobile" type="text" id="txtMobile" class="input_250" maxlength="11"
                            runat="server" onchange="onMobileValidation();" /><span class="td_span_red">*</span>
                    </td>
                </tr>
                <tr>
                    <td width="40%" align="right" class="td1">
                        归属地：
                    </td>
                    <td>
                        <span id="txtPhoneCallsAttribution" name="txtPhoneCallsAttribution"></span>
                    </td>
                </tr>
                <tr>
                    <td width="40%" align="right" class="td1">
                        充值金额：
                    </td>
                    <td>
                        <input name="txtRechargeAmount" type="text" id="txtRechargeAmount" class="input_250"
                            maxlength="4" runat="server" onchange="onRechargeAmountValidation();" /><span readonly="readonly"
                                class="td_span_red">*</span>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="center">
                        <asp:Button ID="btn_save" runat="server" OnClientClick="return CheckInfo();" class="button"
                            Text="保 存" OnClick="btn_save_Click" />
                    </td>
                </tr>
            </table>
            <label id="lblMsg" runat="server">
            </label>
        </div>
    </div>
    </form>

    <script type="text/javascript">
        function CheckInfo() {
            if ($("#txtUserName").val() == "") {
                alert("用户名不能为空");
                $("#txtUserName").focus();
                return false;
            }
            if ($("#txtPassword").val() == "") {
                alert("密码不能为空");
                $("#txtPassword").focus();
                return false;
            }
            if ($("#txtMobile").val() == "") {
                alert("充值手机不能为空");
                $("#txtMobile").focus();
                return false;
            }
            if ($("#txtRechargeAmount").val() == "") {
                alert("充值金额不能为空");
                $("#txtRechargeAmount").focus();
                return false;
            }
            return true;
        }
        function onMobileValidation() {
            var mobileNo = $("#txtMobile").val();
            if (mobileNo != "") {
                var re = new RegExp("^0?(13[0-9]|15[012356789]|18[0236789]|14[57])[0-9]{8}$");
                if (!re.test(mobileNo)) {
                    alert("输入的手机号码格式有误，请重新输入");
                    $("#txtMobile").val("");
                    $("#txtMobile").focus();
                }
                else {
                    $.ajax({
                        url: "service/SystemManageHandler.ashx?action=GetMobileInfo&MobileCode=" + mobileNo,
                        success: function(text) {
                            $("#txtPhoneCallsAttribution").text(text);
                        },
                        error: function(jqXHR, textStatus, errorThrown) {
                            alert(jqXHR.responseText);
                        }
                    });
                }
            }
        }
        function onRechargeAmountValidation() {
            var rechargeAmount = $("#txtRechargeAmount").val();
            if (rechargeAmount != "") {
                if (rechargeAmount < 10 || rechargeAmount > 1000) {
                    alert("充值金额范围10元-1000元，请重新输入");
                    $("#txtRechargeAmount").val("");
                    $("#txtRechargeAmount").focus();
                }
            }
        }
        function onUserNameValidation() {
            var UserName = $("#txtUserName").val();
            if (UserName != "") {
                $.ajax({
                    url: "service/SystemManageHandler.ashx?action=UserNameValidation&UserName=" + UserName,
                    success: function(result) {
                        if (result == 100) {
                            alert("用户名包含非法关键字，请重新输入");
                            $("#txtUserName").val("");
                            $("#txtUserName").focus();
                        }
                        if (result == 200) {
                            alert("用户名不存在，请重新输入");
                            $("#txtUserName").val("");
                            $("#txtUserName").focus();
                        }
                    },
                    error: function(jqXHR, textStatus, errorThrown) {
                        alert(jqXHR.responseText);
                    }
                });
            }
        }
        function onPasswordValidation() {
            var UserName = $("#txtUserName").val();
            var Password = $("#txtPassword").val();
            if (UserName != "" && Password != "") {
                $.ajax({
                    url: "service/SystemManageHandler.ashx?action=PasswordValidation&UserName=" + UserName + "&Password=" + Password,
                    success: function(result) {
                        if (result == 100) {
                            alert("密码包含非法关键字，请重新输入");
                            $("#txtPassword").val("");
                            $("#txtPassword").focus();
                        }
                        if (result == 200) {
                            alert("用户名或密码有误，请重新输入");
                            $("#txtPassword").val("");
                            $("#txtPassword").focus();
                        }
                    },
                    error: function(jqXHR, textStatus, errorThrown) {
                        alert(jqXHR.responseText);
                    }
                });
            }
        }
    </script>

</body>
</html>
